Skip to content

refactor: migrate diagLog to unified os.Logger#5

Closed
Newarr wants to merge 1 commit intorefactor/naming-collisionfrom
refactor/logging-migration-stacked
Closed

refactor: migrate diagLog to unified os.Logger#5
Newarr wants to merge 1 commit intorefactor/naming-collisionfrom
refactor/logging-migration-stacked

Conversation

@Newarr
Copy link
Copy Markdown
Owner

@Newarr Newarr commented Mar 29, 2026

Stacked on yazinsai#232 — after that merges, retarget this PR to main on the upstream repo.

What

Replaces the legacy diagLog() file logger (/tmp/openoats.log) with Apple's unified os.Logger system via a centralized Log enum.

Why

diagLog writes to a flat file on /tmp, bypassing the OS log system. Logs aren't filterable by subsystem, category, or level. They don't show up in Console.app. They persist to disk unconditionally. Three files also used inconsistent Logger subsystems (com.openoats vs com.openoats.app), fragmenting Console queries.

The unified logging system gives: structured filtering (log stream --predicate 'subsystem == "com.openoats.app"'), per-category visibility, automatic privacy redaction in release builds, and zero disk writes for debug-level logs.

How

New file: Utils/Logging.swift with a centralized Log enum providing 7 static Logger instances (mic, recorder, transcription, streaming, transcript, echo, whisperkit). Single subsystem derived from Bundle.main.bundleIdentifier.

69 diagLog calls replaced across 8 files with appropriate log levels:

  • debug for high-frequency audio buffer callbacks (gated behind counters to limit volume)
  • info for lifecycle events (engine start/stop, model loaded, device changed)
  • error for failures (file creation, capture errors, model load)
  • fault for invariant violations (1 case: missing backend)

Privacy annotations:

  • Numeric debug values (frame counts, sample rates): .public
  • Transcript text content: .private (redacted in release builds)
  • File paths: .private(mask: .hash)

Per-file Loggers removed from MicCapture, StreamingTranscriber, and WhisperKitManager in favor of the centralized factory.

Testing

  • swift build passes
  • 304 tests pass, 0 failures
  • grep -rc diagLog Sources/ returns zero matches
  • grep -rn 'Logger(subsystem: "com.openoats"' Sources/ returns zero matches (all subsystems normalized)

Viewing logs after migration

# Stream all OpenOats logs
log stream --predicate 'subsystem == "com.openoats.app"' --level debug

# Filter by category
log stream --predicate 'subsystem == "com.openoats.app" AND category == "MicCapture"'

Replace the legacy `diagLog()` file-based logger (/tmp/openoats.log)
with Apple's unified logging system via a centralized `Log` enum.

Changes:
- Delete `func diagLog(_ msg: String)` from TranscriptionEngine.swift
- Create Utils/Logging.swift with centralized Log enum (6 categories)
- Replace 69 diagLog calls across 8 files with Log.<category>.<level>()
- Normalize all Logger subsystems to com.openoats.app
- Remove per-file Logger instances (MicCapture, StreamingTranscriber,
  WhisperKitManager) in favor of centralized factory
- Add privacy annotations: .public for debug values, .private for
  transcript content, .private(mask: .hash) for file paths
- Log levels: debug for hot-path audio callbacks, info for lifecycle
  events, error for failures, fault for invariant violations

304 tests pass, 0 failures.
@Newarr
Copy link
Copy Markdown
Owner Author

Newarr commented Mar 29, 2026

Superseded by #7, which contains the cleaned-up squashed logging stack.

@Newarr Newarr closed this Mar 29, 2026
@Newarr Newarr deleted the refactor/logging-migration-stacked branch March 29, 2026 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant